<template>
  <div :class="className" :style="{height:height,width:width}"/>
</template>

<script>

import * as echarts from 'echarts'

export default {
  name: "ten",
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '1500px'
    },
    height: {
      type: String,
      default: '750px'
    }
  },
  data() {
    return {
      chart: null,
      option: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')

      this.setOptions()
    },

    setOptions() {
      this.option = {
        title: {
          show: true,
          text: "银行反诈反赌使用情况",
          left: "center",
          top: "1%",
          textStyle: {
            fontSize: 18,
            color: "#293C55",
            fontStyle: "normal",
            fontWeight: "normal"
          }
        },

        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'none'
          }

        },
        legend: {
          show:true,
          top: '10%',
          itemWidth: 20,
          itemHeight: 5,
          textStyle: {
            fontSize: 12,
            lineHeight: 12,
            rich: {
              a: {
                verticalAlign: 'middle',
              },
            },
            padding:[0,0,-2,0],  //[上、右、下、左]
          },
        },
        grid: {
          left: '3%',
          right: '5%',
          bottom: '8%',
          containLabel: true
        },
        yAxis: {
          type: 'value',
          name:"单位：万吨",
          nameTextStyle:{
            color:" rgba(77,77,77,0.70)",
            fontSize: 12,
            padding: 0
          },
          splitLine: {
            show: false,
            lineStyle: {
              color: '#D2E6F9',
              type: 'dashed'
            }
          },
          axisLine: {
            lineStyle: {
              color: '#E0E0E0'
            }
          },
          axisTick: {
            show: false
          },
          axisLabel: {
            color: '#000'
          }
        },
        xAxis: [{
          type: 'category',
          data: ['2023.01','2023.02','2023.03','2023.04','2023.05','2023.06','2023.07'],
          axisLine: {
            lineStyle: {
              color: '#E0E0E0'
            }
          },
          axisTick: {
            show: false
          },
          axisLabel: {
            color: '#888888'
          }
        },{
          type: 'category',
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLabel: {
            show: false
          }
        }],
        series: [
          {
            name: '实时请求',
            xAxisIndex: 1,
            type: 'bar',
            barWidth: 24,
            barGap: '1%',
            data: [2,4,6,8,10,12,14],
            label: {
              show: true,
              fontSize: 14,
              color: '#888888',
              formatter: '{c}',
              position: 'top'
            },
            itemStyle: {
              color: "rgba(61,187,255,.16)",
              borderColor: "#3eb6f5",
              borderWidth: 1,
              borderType: 'solid',
            }
          },
          {
            name: '实时反馈',
            type: 'bar',
            barWidth: 24,
            barGap: '1%',
            data: [1,2,3,4,5,6,7],
            "label": {
              show: true,
              formatter: '{c}' ,
              "position": "left",
              color: 'rgba(119,167,255,1)',
              fontSize: 12,
              textAlign: 'center'
            },
            color: "#3eb6f5"
          },
          {
            name: '批量请求',
            xAxisIndex: 1,
            type: 'bar',
            barWidth: 24,
            barGap: '1%',
            data: [6,12,18,24,30,36,42],
            "label": {
              normal: {
                show: true,
                fontSize: 14,
                color: '#888888',
                formatter: '{c}',
                position: 'top'
              }
            },
            itemStyle: {
              color: "rgba(255,164,41,.16)",
              borderColor: "#ffc241",
              borderWidth: 1,
              borderType: 'solid',

            }
          },{
            name: '批量反馈',
            type: 'bar',
            barWidth: 24,
            barGap: '1%',
            data: [3,6,9,12,15,18,21],
            "label": {
              show: true,
              formatter: '{c}' ,
              "position": "right",
              color: 'rgba(119,167,255,1)',
              fontSize: 12,
              textAlign: 'center'
            },
            color: "#ffc241"
          }

        ]
      };
      this.chart.setOption(this.option)
    }
  }
}
</script>

<style scoped>

</style>
